<?php
/**
 * Created by PhpStorm.
 * User: luoshuqi
 * Date: 19-2-19
 * Time: 上午11:41
 */

namespace App\Utils;

use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Psr\Log\LoggerInterface;

trait LoggerTrait
{
    public function getLogger($name): LoggerInterface
    {
        $file = app()->storagePath("logs/$name/" . date('Y-m-d', $_SERVER['REQUEST_TIME']) . '.log');
        return new Logger($name, [new StreamHandler($file)]);
    }
}